/*
 * 施工模拟组件的model层
 * author:wangxd
 */
// import { getcfDetectionJson } from '../services/mockServices';
// import { getTask, getTaskData, getUsercodeTask } from '../services/bimServices';
import { message } from 'antd';

export default {
  namespace: 'construction',
  state: {
    visible: false, // 施工模拟底部组件
    data: [],
    constructionStartflag: false,
    datatime: {
      endDate: '2019-12-19',
      startDate: '2019-12-19',
      task_day: 1000,
    },
    nowDate: '', // 初始位移时间设定
    moveLinetime: 0, // 进度条初始位移距离
    tableTop: 0, // 表格和图表位移
    leftTableEnd: [], // 表格末尾的切换
    lineoneVisible: true,
    linetwoVisible: true,
    linethreeVisible: true,
    upchildId: [],
    importantLine: false,
    leftlicolor: false,
    scrollTopY: 0, // 左右表格Y轴联动值
    scrollLeftX: 0, // 表格头部标题X轴联动值
    filteridArr: [], // 左侧表格过滤显示构件
    usercodes: null, // 三类usercodes集合
  },
  subscriptions: {},
  effects: {
    // *getcfDetectiondatas({ payload }, { put }) {
    //   if(payload){
    //     const data = yield getTask(payload);
    //     if (data.data.data) {
    //       yield put({
    //         type: 'setcfDetectionContent',
    //         payload: data.data.data,
    //       });
    //     } else {
    //       message.warning('数据异常');
    //     }
    //   }
    // },
    // *getTaskBimdatas({ payload }, { put }) {
    //   if(payload){
    //     const data = yield getTaskData(payload);
    //     if (data.data.data) {
    //       console.log(data.data.data)
    //       yield put({
    //         type: 'setTaskBimdatas',
    //         payload: data.data.data,
    //       });
    //     } else {
    //       message.warning('数据异常');
    //     }
    //   }
    // },
    // *getUsercodedatas({ payload }, { put }) {
    //   if(payload){
    //     const data = yield getUsercodeTask(payload);
    //     if (data.data.data) {
    //       yield put({
    //         type: 'setUsercodes',
    //         payload: data.data.data,
    //       });
    //     } else {
    //       message.warning('数据异常');
    //     }
    //   }
    // },
  },
  reducers: {
    changeVisible(state, action) {
      return { ...state, visible: action.payload };
    },
    setcfDetectionContent(state, action) {
      return { ...state, data: action.payload };
    },
    setUsercodes(state, action) {
      return { ...state, usercodes: action.payload };
    },
    setTaskBimdatas(state, action) {
      return { ...state, datatime: action.payload };
    },
    constructionStart(state, action) {
      return { ...state, constructionStartflag: action.payload };
    },
    setTimego(state, action) {
      return { ...state, nowDate: action.payload };
    },
    changeMoveLinetime(state, action) {
      return { ...state, moveLinetime: action.payload };
    },
    changeTableTop(state, action) {
      return { ...state, tableTop: action.payload };
    },
    changeLeftTableEnd(state, action) {
      return { ...state, leftTableEnd: action.payload };
    },
    setlineoneVisible(state, action) {
      return { ...state, lineoneVisible: action.payload };
    },
    setlinetwoVisible(state, action) {
      return { ...state, linetwoVisible: action.payload };
    },
    setlinethreeVisible(state, action) {
      return { ...state, linethreeVisible: action.payload };
    },
    setUpchildId(state, action) {
      return { ...state, upchildId: action.payload };
    },
    setImportantLine(state, action) {
      return { ...state, importantLine: action.payload };
    },
    setLeftlicolor(state, action) {
      return { ...state, leftlicolor: action.payload };
    },
    setScrollTopY(state, action) {
      return { ...state, scrollTopY: action.payload };
    },
    setScrollLeftX(state, action) {
      return { ...state, scrollLeftX: action.payload };
    },
    setFilteridArr(state, action) {
      return { ...state, filteridArr: action.payload };
    },
  },
};
